package cn.good.yan.apis;

import cn.good.yan.entities.PayDTO;
import cn.good.yan.resp.ResultData;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

/**
 * Feign - 接口
 *
 * @author shengren.yan
 * @create 2024-04-13
 */
@Component
//@FeignClient(value = "cloud-provider-payment", contextId = "PayFeignApi")
// 一般我们先通过网关 - 再去找对应的服务，而不是服务之间的互相调用
@FeignClient(value = "cloud-gateway", contextId = "PayFeignApi")
public interface PayFeignApi {

    @GetMapping(value = "/rescire1")
    String rescire1();

    /**
     * @param payDTO
     * @return
     */
    @PostMapping(value = "/pay/add")
    ResultData addPay(@RequestBody PayDTO payDTO);

    /**
     * 验证：Resilience4j  - 案例1：演示 服务降级和熔断的
     *
     * @return
     */
    @GetMapping(value = "/rescire/{id}")
    String myCircuit(@PathVariable("id") Integer id);

    /**
     * 验证：Resilience4j  - 案例2：演示 限制最大并发 - 请求
     *
     * @return
     */
    @GetMapping(value = "/rescire2/{id}")
    String myCircuit2(@PathVariable("id") Integer id);

    /**
     * 验证：Resilience4j  - 案例3：演示 限流 - 请求
     *
     * @return
     */
    @GetMapping(value = "/rescire3/{id}")
    String myCircuit3(@PathVariable("id") Integer id);

    /**
     * 验证 - Micrometer(Sleuth)进行链路监控的例子
     *
     * @param id
     * @return
     */
    @GetMapping(value = "/m/test/{id}")
    String myMicrometer(@PathVariable("id") Integer id);

    /**
     * GateWay进行网关测试案例01
     *
     * @param id
     * @return
     */
    @GetMapping(value = "/g/gateway/get/{id}")
    public ResultData getById(@PathVariable("id") Integer id);

    /**
     * GateWay进行网关测试案例02
     *
     * @return
     */
    @GetMapping(value = "/g/gateway/info")
    public ResultData<String> getGatewayInfo();


}
